<?php echo $form->create('User', array('action' => 'login','onsubmit'=>'return checklogin()')); ?>
<?php 
    $useremail = null;
    $password = null;
    
//    if(isset($_COOKIE['CakeCookie']['useremail'])){$useremail = $_COOKIE['CakeCookie']['useremail'];}
//    if(isset($_COOKIE['CakeCookie']['password'])){ $password = $_COOKIE['CakeCookie']['password'];}
?>
<!--<div class="login_form_left_bg left"></div>-->
            <div class="form_area left">
                <div class="form_position">
                    <div class="per_form">
                        <div class="left form_left_desc">地址：</div>
                        <div class="left login_form_input"><?php echo $form->text('User.email',array("maxlength"=>"50","style"=>"ime-mode:disabled","autocomplete"=>"off",'onblur' => 'return checkusername()','onkeyup' => 'deletePassIfEmailEmpty()','value'=>$useremail));?></div>
                        <div class="left form_input_alert"><span id="emailerror"><label>*</label>邮件地址不为空</span></div>
                        <div class="clear"></div>
                    </div>
                    <div class="per_form">
                        <div class="left form_left_desc">密码：</div>
                        <div class="left login_form_input"><?php echo $form->password('User.password',array("autocomplete"=>"off",'onblur'=>'return checkpassword()','value'=>$password));?></div>
                        <div class="left form_input_alert"><span id="passworderror"><label>*</label>密码不为空且长度6～32位，字母区分大小写</span></div>
                        <div class="clear"></div>
                    </div>
                    <div class="per_form">
                        <div class="left form_left_desc">验证码：</div>
                        <div class="left login_form_input">
                            <div class="vertification_input"><?php echo $form->text('User.code',array('onblur' => 'return checkcode()')) ;?></div>
                            <div class="switch_vertification">看不清楚？<a href="javascript:void(0)" onclick="return changecode()">换一张</a></div>
                        </div>
                        <div class="left vertification_code"><?php echo $html->image('/users/yz',array('id'=>'showing','align'=>'absmiddle'))?></div>
                        <div class="left form_input_alert"><span id="codederror"><label>*</label>验证码不为空</span></div>
                        <div class="clear"></div>
                    </div> 
                    <div class="per_form">
                        <div class="left form_left_desc"></div>
                        <div class="left login_form_input" >
                             <div class="switch_vertification">
                                <label><input type="checkbox" name="remember" id="rember" value="1" onclick="checkremember(this)" />&nbsp;记住密码&nbsp;&nbsp;&nbsp;&nbsp;</label>
                                <label><input type="checkbox" name="autologin" id="auto" value="1"  onclick="checkauto(this)" />&nbsp;自动登录 </label>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <div class="per_form">
                        <div class="left form_left_desc"></div>
                        <div class="left login_form_input"><input id="loginsubmit" type="submit" value="<?php __('Login'); ?>"/></div>
                        <!-- <div class="left find_pwd">忘记密码？<a href="#">找回密码</a></div> -->
                        <div class="clear"></div>
                    </div>
                </div>
            </div>
        </form>
<script>
function checkusername(){
    if($("#UserEmail").val().trim() == ''){
        $("#emailerror").html('<font color="red">*邮件地址不为空</font>');
        return false;
    }else{
        $("#emailerror").html('<label>*</label>邮件地址不为空');
    }
}
function checkpassword(){
    if($("#UserPassword").val().trim() == '' || $("#UserPassword").val().length < 6 || $("#UserPassword").val().length > 32){
        $("#passworderror").html('<font color="red">*密码不为空且长度6～32位，字母区分大小写</font>');
        return false;
    }else{
        $("#passworderror").html('<label>*</label>密码不为空且长度6～32位，字母区分大小写');
    }
}
function checkcode(){
    if($("#UserCode").val().trim() == '' ){
        $("#codeerror").html('<font color="red">*验证码不为空</font>');
        return false;
    }else{
        $("#codeerror").html('<label>*</label>验证码不为空');
    }
}
function checklogin(){
    if($("#UserEmail").val().trim() == ''){
        $("#emailerror").html('<font color="red">*邮件地址不为空</font>');
        return false;
    }
    if($("#UserPassword").val().trim() == '' || $("#UserPassword").val().length < 6 || $("#UserPassword").val().length > 32){
        $("#passworderror").html('<font color="red">*密码不为空且长度6～32位，字母区分大小写</font>');
        return false;
    }
}
function checkremember(obj){
    if($(obj.id).attr("checked")==true){}
    else{$("#auto").attr("checked",false);}
}
function checkauto(obj){
    if($(obj.id).attr("checked")==false){}
    else{$("#rember").attr("checked",true);}
}

function deletePassIfEmailEmpty()
{
    if($("#UserEmail").val().trim() == '')
    {
        $("#UserPassword").val("");
    }
}
function changecode(){
  var codeurl = $("#getpath").attr('href')+"users/yz/"+Math.random();
  $("#showing").attr("src",codeurl);
  $("#yz").val("");
  return false;
}
</script>